Maintaining a balanced diet is important to maintaining good oral health.
As you may already know cavities are caused by plaque build up. Plaque is a thin film of bacteria that builds up on your teeth. So the more food and or drinks you have that contain high sugar content the higher risks are of plaque developing and leading to cavities. Protect your teeth by having a well balance diet with low sugar. Not to say you can not have those sugary sweets once in a while but try to limit them and remember to brush twice a day and floss daily in order to help reduce plaque build up on your teeth.